package com.hc.trans;

import com.hc.common.bean.PageBean;
import com.hc.constant.SkuConst;
import com.hc.domain.Comment;
import com.hc.query.CommentItem;
import com.hc.res.CommentWithTag;
import com.hc.res.UserComment;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author hc
 * @date 2021/12/24 12:54
 */
@Mapper
public interface CommentTrans {
    CommentTrans MAPPER = Mappers.getMapper(CommentTrans.class);

    /**
     * 将评论和相关的标签打包成CommentWithTag对象
     *
     * @param comment
     * @param titleList
     * @return
     */
    CommentWithTag commentAndTags2CommentWithTag(Comment comment, List<String> titleList);

    /**
     * 将CommentItem中的属性转换到Comment中
     *
     * @param commentItem
     * @return
     */
    @Mapping(target = "status", expression = "java(" + SkuConst.Comment.FIRST + ")")
    Comment commentItem2Comment(CommentItem commentItem);

    PageBean<UserComment> commentPageBean2UserCommentPageBean(PageBean<Comment> commentPageBean);
}
